<template>
  <!-- 店铺卡片组件 start -->
  <div class="shop_card" @click="$emit('click')">
    <div class="shop_card_content">
      <!-- 店铺头像 -->
      <div class="shop_avatar">
        <image
          :src="logo_url"
          mode="aspectFill"
        />
      </div>

      <div class="shop_info">
        <!-- 店铺名称和距离 -->
        <div class="shop_header">
          <div class="shop_name">{{ shop_name }}</div>
        </div>

        <!-- 评分区域 -->
        <div class="rating_row">
          <uni-rate
            :value="rating"
            :size="14"
            :readonly="true"
            allow-half
            color="#e8e8e8"
            active-color="#006cd9"
          />
          <span class="rating_score">{{ rating }}</span>
        </div>

        <!-- 地址信息 -->
        <div class="address_row">
          <span class="address_text">{{ address }}</span>
          <div class="shop_distance">距离{{ distance }}</div>
        </div>

        <!-- 标签信息 -->
        <div class="tag_row">
          <div class="ico">套</div>
          <span class="tag_text">{{ tag_text }}</span>
        </div>
      </div>
    </div>
  </div>
  <!-- 店铺卡片组件 end -->
</template>

<script>
export default {
  name: 'ShopCard',
  props: {
    logo_url: {
      type: String,
      required: true
    },
    shop_name: {
      type: String,
      required: true
    },
    rating: {
      type: Number,
      default: 5.0
    },
    address: {
      type: String,
      default: ''
    },
    distance: {
      type: String,
      default: '1.0km'
    },
    tag_text: {
      type: String,
      default: ''
    }
  },
  emits: ['click']
}
</script>

<style lang="less" scoped>
.shop_card {
  padding: 20rpx;
  background-color: #fff;
  border-radius: 8px;

  .shop_card_content {
    display: flex;
    align-items: flex-start;
  }

  .shop_avatar {
    width: 210rpx;
    height: 210rpx;
    margin-right: 15rpx;

    image {
      width: 100%;
      height: 100%;
      border-radius: 8rpx;
    }
  }

  .shop_info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 210rpx; // 设置固定高度与头像一致
    justify-content: space-between; // 均匀分布子元素
  }

  .shop_header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;

    .shop_name {
      flex: 1;
      font-size: 16px;
      font-weight: bold;
      color: #333;
      margin-right: 10px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .rating_row {
    display: flex;
    align-items: center;
    margin-bottom: 8px;

    .rating_score {
      margin-left: 8px;
      font-size: 14px;
      color: #006cd9;
    }
  }

  .address_row {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .address_text {
      flex: 1;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      margin-right: 10px;
    }
    
    .shop_distance {
      color: #999;
      flex-shrink: 0;
    }
  }

  .tag_row {
    display: flex;
    align-items: center;
    width: 100%;
    margin-top: auto; // 将标签行推到底部
    
    .ico {
      width: 50rpx;
      height: 50rpx;
      margin-right: 10rpx;
      line-height: 50rpx;
      background-color: #ff4d4f;
      color: white;
      font-size: 26rpx;
      text-align: center;
      flex-shrink: 0;
    }
    
    .tag_text {
      font-size: 12px;
      color: #666;
      background-color: #f5f5f5;
      padding: 4px 8px;
      border-radius: 4px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      max-width: calc(100% - 60rpx);
    }
  }
}
</style> 